import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import tag from '../04.mytag App.vue'
import slot from '../02.slot-scope App.vue'
import one from '../tabs/one.vue'
import two from '../tabs/two.vue'
import three from '../tabs/three.vue'
import notfound from '../tabs/404.vue'

Vue.use(VueRouter)

//路由规则配置
const routes = [
  //一个路径对应一个组件
  {
    path: '/',
    name: 'one',
    /**
     * 第一次加载页面时,会先找根路径,然后在路由配置中,redirect重定向
     * 到了其他页面,如果没有找到重新定位的页面,则可以添加一个匹配全局
     * 的404页面来代替
    **/
    // redirect: '/two',
    redirect: '98989',
    component: one
  },

  {
    path: '/two',
    name: 'two',
    component: two
  },

  {
    path: '/three/:id/:name',
    name: 'three',
    component: three
  },

  {
    path: '*', //*号可以匹配所有路径
    name: 'notfound',
    component: notfound
  },



  // {
  //   path: '/',
  //   name: 'home',
  //   component: HomeView
  // },
  // //设置路由配置项,导入所需文件,注册文件.path:路径名称
  // {
  //   path: '/tag',
  //   name: 'tag',
  //   component: tag
  // },
  // {
  //   path: '/slot',
  //   name: 'slot',
  //   component: slot
  // },
  // {
  //   path: '/about',
  //   name: 'about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  // }
]

const router = new VueRouter({
  mode: 'hash',//配置路由模式
  routes,
  linkActiveClass: 'active',//模糊匹配类名
  linkExactActiveClass: 'Thenactive',//精准匹配类名
})

export default router
